package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConst;
import com.itheima.entity.Result;
import com.itheima.pojo.Setmeal;
import com.itheima.service.SetMealService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/setMeal")
@Slf4j
public class SetMealController {

    @Reference
    private SetMealService setMealService;

    @RequestMapping("/findAllSetMeal")
    public Result findAllSetMeal(){
        log.debug("SetMealController: findAllSetMeal: ===> ");
        List<Setmeal> setMealList = setMealService.findAllSetMeal();
        log.debug("SetMealController: findAllSetMeal: setMealList ===> " + setMealList);
        log.debug("查询所有套餐信息成功");
        return new Result(true, MessageConst.QUERY_SETMEAL_SUCCESS,setMealList);
    }

    @RequestMapping("/findById")
    public Result findById(Integer id){
        log.debug("SetMealController: findById: id ===> " + id);
        Setmeal setmeal = setMealService.findById(id);
        log.debug("SetMealController: findById: setmeal ===> " + setmeal);
        log.debug("根据id查询套餐信息成功");
        return new Result(true,MessageConst.QUERY_SETMEAL_SUCCESS,setmeal);
    }

    @RequestMapping("/findSetMealById")
    public Result findSetMealById(Integer id){
        log.debug("SetMealController: findSetMealById: id ===> " + id);
        Setmeal setmeal = setMealService.findSetMealById(id);
        log.debug("SetMealController: findSetMealById: setmeal ===> " + setmeal);
        log.debug("根据id查询套餐信息成功");
        return new Result(true,MessageConst.QUERY_SETMEAL_SUCCESS,setmeal);
    }

}
